package com.midian.service.activity.impl;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.midian.common.dao.BaseDaoTemplet;
import com.midian.common.dao.OrderHelper;
import com.midian.common.dao.SearchHelper;
import com.midian.common.dao.SearchHelper.Type;
import com.midian.common.exception.BizException;
import com.midian.common.pager.Pager;
import com.midian.model.activity.ActivityType;
import com.midian.service.common.BaseService;
import com.midian.service.activity.IActivityTypeService;

/**
 * 活动类型业务实现类
 * @author Mengfh
 *
 */
@Service("activityTypeService")
public class ActivityTypeServiceImpl extends BaseService implements IActivityTypeService {
	/**活动类型DAO*/
	private BaseDaoTemplet<ActivityType> activityTypeDAO;
	
	@Resource(name = "activityTypeDAO")
	public void setActivityTypeDAO(BaseDaoTemplet<ActivityType> activityTypeDAO) {
		this.activityTypeDAO = activityTypeDAO;
	}

	@Override
	public ActivityType add(ActivityType target) throws BizException {
		this.activityTypeDAO.add(target);
		return target;
	}

	@Override
	public void update(ActivityType target) throws BizException {
		this.activityTypeDAO.updateByConvertHql(target);
	}

	@Override
	public void delete(Serializable id) throws BizException {
		this.activityTypeDAO.delete(id);
	}

	@Override
	public void delete(Serializable[] ids) throws BizException {
		this.activityTypeDAO.delete(ids);
	}

	@Override
	public ActivityType get(Serializable id) throws BizException {
		return this.activityTypeDAO.get(id);
	}

	@Override
	public List<ActivityType> showList(ActivityType target, Pager pager, List<OrderHelper> helper) throws BizException {
		return this.activityTypeDAO.find(target, getSearchHelper(), helper, pager);
	}

	@Override
	public void opDelFlag(Serializable[] ids, Integer status) throws BizException {
		this.activityTypeDAO.opDelFlag(ids, status);
	}

	@Override
	protected List<SearchHelper> getSearchHelper() {
		String[] attrs = {};
		Type[] types = {};
		return SearchHelper.getSearchList(attrs, types);
	}

	@Override
	public List<ActivityType> getAllTypes() {
		String hql = "from ActivityType o where o.delFlag = 1 ";
		return activityTypeDAO.find(hql);
	}
}
